package com.rdzn.mall.center.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.rdzn.mall.center.entity.SmsCoupon;
import com.rdzn.mall.center.mapper.SmsCouponMapper;
import com.rdzn.mall.center.service.ISmsCouponService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: sms_coupon
 * @Author: jeecg-boot
 * @Date:   2020-08-27
 * @Version: V1.0
 */

@Service
public class SmsCouponServiceImpl extends ServiceImpl<SmsCouponMapper, SmsCoupon> implements ISmsCouponService {

    @Override
    public SmsCoupon getByCode(String code) {
        List<SmsCoupon> coupons = list(new LambdaQueryWrapper<SmsCoupon>().eq(SmsCoupon::getCode, code));
        if (CollectionUtils.isNotEmpty(coupons)){
            return coupons.get(0);
        }
        return null;
    }

}
